package com.kuang.demo02;

import java.util.concurrent.CopyOnWriteArrayList;

/**测试JUC安全类型的包
 * @author FHL
 * 这个集合是线程安全的
 */
public class TestJUCList {
    public static void main(String[] args) {
        CopyOnWriteArrayList<String> list=new CopyOnWriteArrayList<>();
        for (int i = 0; i < 100; i++) {
            new Thread(()->{
                list.add(Thread.currentThread().getName());
            }).start();
        }
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(list.size());
    }
}
